#include "player.h"

Player::ptr PlayerManager::get(int fd)
{
    if(m_players.count(fd) == 0)
    {
        Player::ptr player(new Player(fd));
        m_players[fd] = player;
        return player;
    }
    else
    {
        return m_players[fd];
    }
}

void PlayerManager::del(int fd)
{
    if(m_players.count(fd) != 0)
    {
        m_players[fd].reset();
        m_players.erase(fd);
    }
}

bool Player::operator==(const Player::ptr& player)
{
    return this->m_id == player->m_id;
}